package com.camelot.boot.module.system.controller.admin.ai;

import com.camelot.boot.framework.apilog.core.annotation.ApiAccessLog;
import com.camelot.boot.framework.common.enums.CommonStatusEnum;
import com.camelot.boot.framework.common.pojo.CommonResult;
import com.camelot.boot.framework.common.pojo.PageParam;
import com.camelot.boot.framework.common.pojo.PageResult;
import com.camelot.boot.framework.common.util.object.BeanUtils;
import com.camelot.boot.framework.excel.core.util.ExcelUtils;
import com.camelot.boot.module.system.controller.admin.dict.vo.data.DictDataPageReqVO;
import com.camelot.boot.module.system.controller.admin.dict.vo.data.DictDataRespVO;
import com.camelot.boot.module.system.controller.admin.dict.vo.data.DictDataSaveReqVO;
import com.camelot.boot.module.system.controller.admin.dict.vo.data.DictDataSimpleRespVO;
import com.camelot.boot.module.system.dal.dataobject.dict.DictDataDO;
import com.camelot.boot.module.system.service.dict.DictDataService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

import static com.camelot.boot.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.camelot.boot.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 字典数据")
@RestController
@RequestMapping("/system/ai")
@Validated
public class AIController {

    @Resource
    private DictDataService dictDataService;

    @PostMapping("/create")

    public CommonResult<Long> createDictData(@Valid @RequestBody DictDataSaveReqVO createReqVO) {
        Long dictDataId = dictDataService.createDictData(createReqVO);
        return success(dictDataId);
    }

    @Resource
    private DeepSeekService deepSeekService;

    @GetMapping
    @RequestMapping("/chat")
    @PermitAll
    public String chat(String question) {
        try {
            return deepSeekService.chat(question);
        } catch (IOException e) {
            return "服务器繁忙，请稍后重试！";
        }
    }


}
